import os

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver import Chrome
import time
class Browser_drvice(object):
    def browser_init(self):
        os.environ['WDM_SSL_VERIFY'] = "false"
        #自动下载对应的驱动
        driver= webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
        # driver.get("https://www.baidu.com")
        # time.sleep(30)
        return driver

    def test(self):

        # 1、创建浏览器对象(生活中已经打开了浏览器)
        b = Chrome()

        # 2、用浏览器打开指定网页（输入网址）
        b.get(' https://movie.douban.com/top250')

        # 3、获取打开的网页的网页源代码
        print(b.page_source)

if __name__ == '__main__':
    Browser_drvice().browser_init()
    Browser_drvice().test()